home *** CD-ROM | disk | FTP | other *** search
- /*
- * @(#) pscpu.c 9.2 93/09/15 SCOINC
- */
- /***************************************************************************
- *
- * Copyright (c) 1990-1993 The Santa Cruz Operation, Inc.
- *
- * All rights reserved. No part of this program or publication may be
- * reproduced, transmitted, transcribed, stored in a retrieval system,
- * or translated into any language or computer language, in any form or
- * by any means, electronic, mechanical, magnetic, optical, chemical,
- * biological, or otherwise, without the prior written permission of:
- *
- * The Santa Cruz Operation , Inc. (408) 425-7222
- * 400 Encinal St., Santa Cruz, California 95060 USA
- *
- **************************************************************************/
- /*
- * Modification History
- *
- * S002, 15-Sep-93, rickra
- * Did lots of little bug fixes...
- *
- * S001, 27-May-93, rickra
- * Did alot of stuff.....
- * Added seperate window support.
- * Added pixmap support.....
- *
- * S000, 30-Sep-92, rickra
- * Added copyright and modification history
- * Change hard coded color referneces to user configurable.
- */
- /*+-------------------------------------------------------------------------
- pscpu.c - XSW proc status detail
-
- Defined functions:
- display_proc_stat(x,y,iproc)
- --------------------------------------------------------------------------*/
-
- #include <X11/Xlib.h>
- #include <X11/Xutil.h>
- #include <X11/Intrinsic.h>
- #include <X11/Shell.h>
- #include <X11/StringDefs.h>
- #include <Xm/Xm.h>
- #include <Xm/MainW.h>
- #include <Xm/DrawingA.h>
- #include <Xm/Label.h>
-
- #include "include/unixincs.h"
- #include "include/resources.h"
- #include "include/xswboth.h"
- #include "include/buttons.h"
- #include "include/libkmem.h"
- #include "include/libmem.h"
- #include "include/libswap.h"
-
- #include "include/xsw.h"
-
- extern struct NetworkXswStruct *current_server;
-
- extern struct my_user_struct user;
- extern struct my_user_struct old_user;
-
- extern Pixmap pixmap;
-
-
- long total_ps_ticks = 0;
-
- /*+-----------------------------------------------------------------------
- char *get_cpu_time_str(ticks)
- 6-char static string address is returned
- ------------------------------------------------------------------------*/
- char *
- get_cpu_time_str (ticks)
- time_t ticks;
- {
- static char timestr[10];
- time_t mm, ss;
-
- ticks /= current_server -> hz;
- mm = ticks / 60L;
- ticks -= mm * 60L;
- ss = ticks;
-
- if (mm > 9999)
- (void) strcpy (timestr, ">9999m");
- else if (mm > 999)
- (void) sprintf (timestr, "%5ldm", mm);
- else
- (void) sprintf (timestr, "%3lu:%02lu", mm, ss);
-
- return (timestr);
-
- } /* end of get_cpu_time_str */
-
-
- /*+-------------------------------------------------------------------------
- ppproc_state_compare(ppp1,ppp2)
- --------------------------------------------------------------------------*/
- ppproc_state_compare (ppp1, ppp2)
- struct my_proc_struct **ppp1;
- struct my_proc_struct **ppp2;
- {
-
- if (((*ppp1) -> p_pid == 32767) && ((*ppp2) -> p_pid == 32767))
- return (0);
- else if ((*ppp1) -> p_pid == 32767)
- return (1);
- else if ((*ppp2) -> p_pid == 32767)
- return (-1);
-
- if (current_server -> ps_cpu_sort_order == 1)
- return ((*ppp2) -> p_stat - (*ppp1) -> p_stat);
- else
- return ((*ppp1) -> p_stat - (*ppp2) -> p_stat);
-
- } /* end of ppproc_state_compare */
-
-
- /*+-------------------------------------------------------------------------
- ppproc_user_compare(ppp1,ppp2)
- --------------------------------------------------------------------------*/
- ppproc_user_compare (ppp1, ppp2)
- struct my_proc_struct **ppp1;
- struct my_proc_struct **ppp2;
- {
-
- if (((*ppp1) -> p_pid == 32767) && ((*ppp2) -> p_pid == 32767))
- return (0);
- else if ((*ppp1) -> p_pid == 32767)
- return (1);
- else if ((*ppp2) -> p_pid == 32767)
- return (-1);
-
- if (current_server -> ps_cpu_sort_order == 1)
- return (strcmp ((*ppp2) -> name, (*ppp1) -> name));
- else
- return (strcmp ((*ppp1) -> name, (*ppp2) -> name));
-
- } /* end of ppproc_user_compare */
-
- /*+-------------------------------------------------------------------------
- ppproc_pid_compare(ppp1,ppp2)
- --------------------------------------------------------------------------*/
- ppproc_pid_compare (ppp1, ppp2)
- struct my_proc_struct **ppp1;
- struct my_proc_struct **ppp2;
- {
- if (((*ppp1) -> p_pid == 32767) && ((*ppp2) -> p_pid == 32767))
- return (0);
- else if ((*ppp1) -> p_pid == 32767)
- return (1);
- else if ((*ppp2) -> p_pid == 32767)
- return (-1);
-
- if (current_server -> ps_cpu_sort_order == 1)
- return ((*ppp2) -> p_pid - (*ppp1) -> p_pid);
- else
- return ((*ppp1) -> p_pid - (*ppp2) -> p_pid);
- } /* end of ppproc_pid_compare */
-
- /*+-------------------------------------------------------------------------
- ppproc_cpu_compare(ppp1,ppp2)
- --------------------------------------------------------------------------*/
- ppproc_cpu_compare (ppp1, ppp2)
- struct my_proc_struct **ppp1;
- struct my_proc_struct **ppp2;
- {
-
- if (((*ppp1) -> p_pid == 32767) && ((*ppp2) -> p_pid == 32767))
- return (0);
- else if ((*ppp1) -> p_pid == 32767)
- return (1);
- else if ((*ppp2) -> p_pid == 32767)
- return (-1);
-
- if (current_server -> ps_cpu_sort_order == 1)
- return ((*ppp2) -> p_cpu - (*ppp1) -> p_cpu);
- else
- return ((*ppp1) -> p_cpu - (*ppp2) -> p_cpu);
-
- } /* end of ppproc_cpu_compare */
-
- /*+-------------------------------------------------------------------------
- ppproc_pri_compare(ppp1,ppp2)
- --------------------------------------------------------------------------*/
- ppproc_pri_compare (ppp1, ppp2)
- struct my_proc_struct **ppp1;
- struct my_proc_struct **ppp2;
- {
-
- if (((*ppp1) -> p_pid == 32767) && ((*ppp2) -> p_pid == 32767))
- return (0);
- else if ((*ppp1) -> p_pid == 32767)
- return (1);
- else if ((*ppp2) -> p_pid == 32767)
- return (-1);
-
- if (current_server -> ps_cpu_sort_order == 1)
- return ((*ppp2) -> p_pri - (*ppp1) -> p_pri);
- else
- return ((*ppp1) -> p_pri - (*ppp2) -> p_pri);
-
- } /* end of ppproc_pri_compare */
-
-
- /*+-------------------------------------------------------------------------
- ppproc_ni_compare(ppp1,ppp2)
- --------------------------------------------------------------------------*/
- ppproc_ni_compare (ppp1, ppp2)
- struct my_proc_struct **ppp1;
- struct my_proc_struct **ppp2;
- {
-
- if (((*ppp1) -> p_pid == 32767) && ((*ppp2) -> p_pid == 32767))
- return (0);
- else if ((*ppp1) -> p_pid == 32767)
- return (1);
- else if ((*ppp2) -> p_pid == 32767)
- return (-1);
-
-
- if (current_server -> ps_cpu_sort_order == 1)
- return ((*ppp2) -> p_nice - (*ppp1) -> p_nice);
- else
- return ((*ppp1) -> p_nice - (*ppp2) -> p_nice);
-
- } /* end of ppproc_ni_compare */
-
- /*+-------------------------------------------------------------------------
- ppproc_ucpu_compare(ppp1,ppp2)
- --------------------------------------------------------------------------*/
- ppproc_ucpu_compare (ppp1, ppp2)
- struct my_proc_struct **ppp1;
- struct my_proc_struct **ppp2;
- {
- struct my_user_struct user1;
- struct my_user_struct user2;
- struct my_user_struct old_user1;
- struct my_user_struct old_user2;
- int i, j, k, l;
-
- i = get_user (&(**ppp1), &user1);
-
- j = get_user (&(**ppp2), &user2);
-
- k = get_old_user (&(**ppp1), &old_user1);
-
- l = get_old_user (&(**ppp2), &old_user2);
-
- if (((*ppp1) -> p_pid == 32767) && ((*ppp2) -> p_pid == 32767))
- return (0);
- else if (((*ppp1) -> p_pid == 32767) || (!i))
- return (1);
- else if (((*ppp2) -> p_pid == 32767) || (!j))
- return (-1);
-
- if (current_server -> ps_cpu_sort_order == 1)
- {
- if (current_server -> ps_display_mode == 13)
- return (user2.u_utime - user1.u_utime);
- else
- return ((user2.u_utime - old_user2.u_utime) -
- (user1.u_utime - old_user1.u_utime));
- }
- else
- {
- if (current_server -> ps_display_mode == 13)
- return (user1.u_utime - user2.u_utime);
- else
- return ((user1.u_utime - old_user1.u_utime) -
- (user2.u_utime - old_user2.u_utime));
-
-
- }
-
-
- } /* end of ppproc_ucpu_compare */
-
- /*+-------------------------------------------------------------------------
- ppproc_ucpu_scpu_compare(ppp1,ppp2)
- --------------------------------------------------------------------------*/
- ppproc_ucpu_scpu_compare (ppp1, ppp2)
- struct my_proc_struct **ppp1;
- struct my_proc_struct **ppp2;
- {
- struct my_user_struct user1;
- struct my_user_struct user2;
- struct my_user_struct old_user1;
- struct my_user_struct old_user2;
- int i, j, k, l;
- i = get_user (&(**ppp1), &user1);
-
- j = get_user (&(**ppp2), &user2);
-
- k = get_old_user (&(**ppp1), &old_user1);
-
- l = get_old_user (&(**ppp2), &old_user2);
-
-
- if (((*ppp1) -> p_pid == 32767) && ((*ppp2) -> p_pid == 32767))
- return (0);
- else if (((*ppp1) -> p_pid == 32767) || (!i))
- return (1);
- else if (((*ppp2) -> p_pid == 32767) || (!j))
- return (-1);
-
-
- if (current_server -> ps_cpu_sort_order == 1)
- {
- if (current_server -> ps_display_mode == 13)
- return ((user2.u_utime + user2.u_stime) -
- (user1.u_utime + user1.u_stime));
- else
- return (((user2.u_utime + user2.u_stime) -
- (old_user2.u_utime + old_user2.u_stime)) -
- ((user1.u_utime + user1.u_stime) -
- (old_user1.u_utime + old_user1.u_stime)));
- }
- else
- {
- if (current_server -> ps_display_mode == 13)
- return ((user1.u_utime + user1.u_stime) -
- (user2.u_utime + user2.u_stime));
- else
- return (((user1.u_utime + user1.u_stime) -
- (old_user1.u_utime + old_user1.u_stime)) -
- ((user2.u_utime + user2.u_stime) -
- (old_user2.u_utime + old_user2.u_stime)));
-
- }
-
- } /* end of ppproc_ucpu_scpu_compare */
-
- /*+-------------------------------------------------------------------------
- ppproc_scpu_compare(ppp1,ppp2)
- --------------------------------------------------------------------------*/
- ppproc_scpu_compare (ppp1, ppp2)
- struct my_proc_struct **ppp1;
- struct my_proc_struct **ppp2;
- {
- struct my_user_struct user1;
- struct my_user_struct user2;
- struct my_user_struct old_user1;
- struct my_user_struct old_user2;
- int i, j, k, l;
- i = get_user (&(**ppp1), &user1);
-
- j = get_user (&(**ppp2), &user2);
-
- k = get_old_user (&(**ppp1), &old_user1);
-
- l = get_old_user (&(**ppp2), &old_user2);
-
-
- if (((*ppp1) -> p_pid == 32767) && ((*ppp2) -> p_pid == 32767))
- return (0);
- else if (((*ppp1) -> p_pid == 32767) || (!i))
- return (1);
- else if (((*ppp2) -> p_pid == 32767) || (!j))
- return (-1);
-
- if (current_server -> ps_cpu_sort_order == 1)
- {
- if (current_server -> ps_display_mode == 13)
- return (user2.u_stime - user1.u_stime);
- else
- return ((user2.u_stime - old_user2.u_stime) -
- (user1.u_stime - old_user1.u_stime));
- }
- else
- {
- if (current_server -> ps_display_mode == 13)
- return (user1.u_stime - user2.u_stime);
- else
- return ((user1.u_stime - old_user1.u_stime) -
- (user2.u_stime - old_user2.u_stime));
-
- }
-
- } /* end of ppproc_scpu_compare */
-
- /*+-------------------------------------------------------------------------
- ppproc_size_compare(ppp1,ppp2)
- --------------------------------------------------------------------------*/
- ppproc_size_compare (ppp1, ppp2)
- struct my_proc_struct **ppp1;
- struct my_proc_struct **ppp2;
- {
- struct my_user_struct user1;
- struct my_user_struct user2;
- int i, j;
-
- i = get_user (&(**ppp1), &user1);
-
- j = get_user (&(**ppp2), &user2);
-
-
- if (((*ppp1) -> p_pid == 32767) && ((*ppp2) -> p_pid == 32767))
- return (0);
- else if (((*ppp1) -> p_pid == 32767) || (!i))
- return (1);
- else if (((*ppp2) -> p_pid == 32767) || (!j))
- return (-1);
-
- if (current_server -> ps_cpu_sort_order == 1)
- return ((user2.u_dsize + user2.u_ssize) -
- (user1.u_dsize + user1.u_ssize));
- else
- return ((user1.u_dsize + user1.u_ssize) -
- (user2.u_dsize + user2.u_ssize));
-
-
- } /* end of ppproc_size_compare */
-
- /*+-------------------------------------------------------------------------
- ppproc_tty_compare(ppp1,ppp2)
- --------------------------------------------------------------------------*/
- ppproc_tty_compare (ppp1, ppp2)
- struct my_proc_struct **ppp1;
- struct my_proc_struct **ppp2;
- {
-
- if (((*ppp1) -> p_pid == 32767) && ((*ppp2) -> p_pid == 32767))
- return (0);
- else if ((*ppp1) -> p_pid == 32767)
- return (1);
- else if ((*ppp2) -> p_pid == 32767)
- return (-1);
-
- return (strcmp ((*ppp1) -> tty, (*ppp2) -> tty));
-
- } /* end of ppproc_tty_compare */
-
- /*+-------------------------------------------------------------------------
- ppproc_cmd_compare(ppp1,ppp2)
- --------------------------------------------------------------------------*/
- ppproc_cmd_compare (ppp1, ppp2)
- struct my_proc_struct **ppp1;
- struct my_proc_struct **ppp2;
- {
- struct my_user_struct user1;
- struct my_user_struct user2;
- int i, j;
-
- i = get_user (&(**ppp1), &user1);
-
- j = get_user (&(**ppp2), &user2);
-
-
- if (((*ppp1) -> p_pid == 32767) && ((*ppp2) -> p_pid == 32767))
- return (0);
- else if ((*ppp1) -> p_pid == 32767)
- return (1);
- else if ((*ppp2) -> p_pid == 32767)
- return (-1);
-
- if (current_server -> ps_cpu_sort_order == 1)
- return (strcmp (user2.u_psargs, user1.u_psargs));
- else
- return (strcmp (user1.u_psargs, user2.u_psargs));
-
- } /* end of ppproc_cmd_compare */
-
- #define PROC_Y 1
- #define PROC_X 0
- #define UID_X 2
- #define PID_X 12
- #define CPU_X 18
- #define PRI_X 22
- #define NICE_X 26
- #define UTIME_X 29
- #define STIME_X 36
- #define SIZE_X 43
- #define TTY_X 48
- #define CMD_X 52
-
- /*+-------------------------------------------------------------------------
- display_proc_stat(x,y,iproc)
- 00000000001111111111222222222233333333334444444444555555555566666666667777777777
- 01234567890123456789012345678901234567890123456789012345678901234567890123456789
- S USER PID CPU PRI NI UCPU SCPU SIZE TTY CMD
- #!########X ##### ### ### ## ###### ###### #### ### ########
- --------------------------------------------------------------------------*/
- void
- display_proc_stat (window, display, gc, DrawAreaXYWH, x, y, pixmap, iproc)
- Window window;
- Display *display;
- GC gc;
- XWindowAttributes DrawAreaXYWH;
- int x;
- int y;
- Pixmap pixmap;
- register int iproc;
- {
-
- int x2 = x;
- register struct my_proc_struct *tproc = current_server -> pprocs[iproc];
- struct my_proc_struct *oproc = current_server -> poldprocs[iproc];
- int got_user = 0;
- int got_old_user = 0;
- char *p_stat_str = " sRzdipx"; /* dependent on values of
- * SSLEEP etc */
- char *cptr;
- char s80[80];
- int fwidth = FWIDTH;
- unsigned long pixel;
-
-
- pixel = colorPScpuIdle.pixel;
-
- got_user = get_user (tproc, &user);
- got_old_user = get_old_user (tproc, &old_user);
-
- if ((tproc -> p_stat == SRUN) && !(tproc -> p_flag & SLOAD))
- pixel = colorPScpuRunning.pixel; /* Do we really need this?? */
- else if (tproc -> p_stat == SRUN)
- pixel = colorPScpuRunning.pixel;
- else if (got_user)
- {
- if (got_old_user)
- {
- if ((old_user.u_utime + old_user.u_stime) !=
- (user.u_utime + user.u_stime))
- pixel = colorPScpuActive.pixel;
-
- }
- else
- pixel = colorPScpuNew.pixel;
-
- }
-
-
- /*
- * Clear the line.....
- */
-
- XSetForeground (display, gc, background);
- XFillRectangle (display, pixmap, gc,0, y,
- current_server -> SEPERATE_WINDOWS_LIST[BUTTON_ps_cpu].draw_width,
- FHEIGHT);
-
-
- /*
- * Display process flag
- */
-
- s80[0] = p_stat_str[tproc -> p_stat];
- s80[1] = 0;
- x2 += disp_info_text (window, display, gc, DrawAreaXYWH, x2, y, pixmap, pixel, s80);
- s80[0] = (tproc -> p_flag & SLOAD) ? ' ' : 'S';
- x2 += disp_info_text (window, display, gc, DrawAreaXYWH, x2, y, pixmap, pixel, s80);
-
- /*
- * Display user name
- */
-
- (void) sprintf (s80, "%8s", tproc -> name);
- x2 += disp_info_text (window, display, gc, DrawAreaXYWH, x2, y, pixmap, pixel, s80);
-
-
- /*
- * Display set uid
- */
-
- s80[0] = (tproc -> p_uid != tproc -> p_suid) ? '#' : ' ';
- s80[1] = ' ';
- s80[2] = 0;
- x2 += disp_info_text (window, display, gc, DrawAreaXYWH, x2, y, pixmap, pixel, s80);
-
- /*
- * Display pid
- */
-
- (void) sprintf (s80, "%5d ", tproc -> p_pid);
- x2 += disp_info_text (window, display, gc, DrawAreaXYWH, x2, y, pixmap, pixel, s80);
-
- /*
- * Display cpu
- */
-
- (void) sprintf (s80, "%3u ", tproc -> p_cpu);
- x2 += disp_info_text (window, display, gc, DrawAreaXYWH, x2, y, pixmap, pixel, s80);
-
- /*
- * Display pri
- */
-
- (void) sprintf (s80, "%3u ", tproc -> p_pri);
- x2 += disp_info_text (window, display, gc, DrawAreaXYWH, x2, y, pixmap, pixel, s80);
-
- /*
- * Display nice
- */
-
- (void) sprintf (s80, "%2d ", tproc -> p_nice);
- x2 += disp_info_text (window, display, gc, DrawAreaXYWH, x2, y, pixmap, pixel, s80);
-
- /*
- * Display cpu times
- */
-
-
-
-
-
- /* since not saving user area, always update fields from it */
-
- if (got_user)
- {
- if (current_server -> ps_display_mode == 13)
- {
-
- if (current_server -> ps_cpu_time_mode == 0)
- {
- strcpy (s80, get_cpu_time_str (user.u_utime));
- strcat (s80, " ");
- strcat (s80, get_cpu_time_str (user.u_stime));
- strcat (s80, " ");
- strcat (s80, get_cpu_time_str (user.u_utime + user.u_stime));
- strcat (s80, " ");
- x2 += disp_info_text (window, display, gc, DrawAreaXYWH,
- x2, y, pixmap, pixel, s80);
- }
- else if (current_server -> ps_cpu_time_mode == 1)
- {
- /*
- fprintf(stdout,"Boot_time = %ld\n",current_server -> boot_time);
- fprintf(stdout,"user.u_utime %ld\n",user.u_utime);
- fprintf(stdout,"user.u_utime * 100 / boot_time %ld\n",
- (user.u_utime * 100 ) /
- current_server -> boot_time);
- fprintf(stdout,"FLOAT user.u_utime * 100 / boot_time %f\n",
- (user.u_utime * 100 ) /
- current_server -> boot_time);
- */
-
- sprintf (s80, " %5.2f %5.2f %5.2f ", (
- (float) (user.u_utime * 100) /
- current_server -> boot_time),
- (
- (float) (user.u_stime * 100) /
- current_server -> boot_time),
- (
- (float) ((user.u_utime + user.u_stime) * 100) /
- current_server -> boot_time));
-
- x2 += disp_info_text (window, display, gc, DrawAreaXYWH, x2, y, pixmap, pixel, s80);
- }
-
-
- }
- else
- {
-
-
- total_ps_ticks += (user.u_utime - old_user.u_utime) +
- (user.u_stime - old_user.u_stime);
-
- if (current_server -> ps_cpu_time_mode == 2)
- {
- if (got_old_user)
- (void) sprintf (s80, "%6d %6d %6d ",
- user.u_utime - old_user.u_utime,
- user.u_stime - old_user.u_stime,
- (user.u_utime - old_user.u_utime) +
- (user.u_stime - old_user.u_stime));
- else
- (void) sprintf (s80, "%6d %6d %6d ",
- user.u_utime,
- user.u_stime,
- (user.u_utime) +
- (user.u_stime));
-
- x2 += disp_info_text (window, display, gc,
- DrawAreaXYWH, x2, y, pixmap, pixel, s80);
- }
- else if (current_server -> ps_cpu_time_mode == 1)
- {
- if (got_old_user)
- sprintf (s80, " %5.2f %5.2f %5.2f ", (
- (float) ((user.u_utime - old_user.u_utime) * 100) /
-
- ((current_server -> StatPeriod_msec / 1000) *
- current_server -> hz)),
-
- (
- (float) ((user.u_stime - old_user.u_stime) * 100) /
- (((float) current_server -> StatPeriod_msec / 1000) *
- current_server -> hz)),
-
- (
- (float) (((user.u_utime - old_user.u_utime) +
- (user.u_stime - old_user.u_stime)) * 100) /
- (((float) current_server -> StatPeriod_msec / 1000) *
- current_server -> hz)));
- else
-
- sprintf (s80, " %5.2f %5.2f %5.2f ", (
- (float) ((user.u_utime) * 100) /
-
- ((current_server -> StatPeriod_msec / 1000) *
- current_server -> hz)),
-
- (
- (float) ((user.u_stime) * 100) /
- (((float) current_server -> StatPeriod_msec / 1000) *
- current_server -> hz)),
-
- (
- (float) (((user.u_utime) +
- (user.u_stime)) * 100) /
- (((float) current_server -> StatPeriod_msec / 1000) *
- current_server -> hz)));
-
- x2 += disp_info_text (window, display, gc, DrawAreaXYWH, x2, y, pixmap, pixel, s80);
- }
- }
-
-
- (void) sprintf (s80, "%4lu ",
- (ctob (user.u_dsize + user.u_ssize)) / BSIZE);
-
- x2 += disp_info_text (window, display, gc, DrawAreaXYWH, x2, y, pixmap, pixel, s80);
- }
- else
- x2 += disp_info_text (window, display, gc, DrawAreaXYWH, x2, y, pixmap, pixel, "------ ------ ------ ---- ");
-
-
- /*
- * Display tty
- */
-
- (void) sprintf (s80, "%3.3s ", tproc -> tty);
- x2 += disp_info_text (window, display, gc, DrawAreaXYWH, x2, y, pixmap, pixel, s80);
-
- /*
- * Need to change to 200 TO DiplayWidth - x2 perhaps....
- *
- * FIX THIS>.....
- */
- /*
- XClearArea (display, window, x2, y, FWIDTH * 200, FHEIGHT, 0);
- */
-
- XSetForeground (display, gc, background);
- XFillRectangle (display, pixmap, gc, x2, y,
- current_server -> SEPERATE_WINDOWS_LIST[BUTTON_ps_cpu].width - x2,
- FHEIGHT);
-
-
-
- XSetForeground (display, gc, pixel);
- if (got_user)
- {
- XDrawString (display, pixmap, gc, x2, y + FASCENT,
- user.u_psargs, strlen (user.u_psargs));
- }
- else
- {
- switch (tproc -> p_stat)
- {
- case SZOMB:
- cptr = "<zombie>";
- break;
- case SXBRK:
- cptr = "<xbreak>";
- break;
- case SIDL:
- cptr = "<in creation>";
- break;
- default:
- cptr = "<swap in progress>";
- }
- /*
- XDrawString (display, window, gc, x2, y + FASCENT, cptr, strlen (cptr));
- */
- XDrawString (display, pixmap, gc, x2, y + FASCENT, cptr, strlen (cptr));
- }
-
-
- } /* end of display_proc_stat */
-
- /*+-------------------------------------------------------------------------
- update_ps_cpu (server_pointer)
- --------------------------------------------------------------------------*/
- void
- update_ps_cpu (server_pointer)
- struct NetworkXswStruct *server_pointer;
-
- {
-
- Window window = server_pointer ->
- SEPERATE_WINDOWS_LIST[BUTTON_ps_cpu].window;
- Display *display = server_pointer ->
- SEPERATE_WINDOWS_LIST[BUTTON_ps_cpu].display;
- GC gc = server_pointer ->
- SEPERATE_WINDOWS_LIST[BUTTON_ps_cpu].gc;
- Pixmap pixmap = server_pointer ->
- SEPERATE_WINDOWS_LIST[BUTTON_ps_cpu].pixmap;
-
- int x = 0;
- int y = 0;
-
-
- register int iproc;
- int fheight = FHEIGHT;
- int yl1 = y + (FASCENT / 2);
- int i;
- int current_ps_number = 0;
- int got_user;
- int got_old_user;
-
- struct my_proc_struct *tproc;
-
-
- /*
- * Create the Label widgets if neccesary, incresing the number if neccesary...
- */
-
- sort_procs (BUTTON_ps_cpu);
-
- y = 0;
-
- total_ps_ticks = 0;
- if (current_server -> ps_display_mode == 13)
- {
- for (iproc = 0; iproc < current_server -> nprocs; iproc++)
- {
- display_proc_stat (window, display, gc, DrawAreaXYWH,
- x, y + (iproc * fheight), pixmap,
- iproc);
- }
- y += (iproc * fheight);
- }
- else
- {
-
- current_ps_number = 0;
-
- for (iproc = 0; iproc < current_server -> nprocs; iproc++)
- {
-
- tproc = current_server -> pprocs[iproc];
- got_user = get_user (tproc, &user);
-
- if (got_user)
- {
- if (got_old_user = get_old_user (tproc, &old_user))
- {
- if (((old_user.u_utime + old_user.u_stime) !=
- (user.u_utime + user.u_stime)) &&
- ((user.u_utime - old_user.u_utime) >= 0) &&
- ((user.u_stime - old_user.u_stime) >= 0)
- )
- {
-
- display_proc_stat (window, display, gc, DrawAreaXYWH,
- x, y + (current_ps_number * fheight),
- pixmap,
- iproc);
- current_ps_number++;
- }
-
-
- }
- }
-
-
- }
- /*
- fprintf(stdout,"Total ps ticks = %ld\n",total_ps_ticks);
- */
-
- y += (current_ps_number * fheight);
-
-
- }
-
-
- /*
- * Clear the remaining pixmap.....
- */
-
- XSetForeground (display, gc, background);
- XFillRectangle (display, pixmap, gc,
- x, y,
- current_server -> SEPERATE_WINDOWS_LIST[BUTTON_ps_cpu].draw_width,
- current_server -> SEPERATE_WINDOWS_LIST[BUTTON_ps_cpu].draw_height);
-
- } /* end of update_ps_cpu */
-
- /* vi: set tabstop=4 shiftwidth=4: */
- /* end of pscpu.c */
-